<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,minimum-scale=1,maximum-scale=1">


<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



  <meta name="description" content="mongodb"/>




  <meta name="keywords" content="node," />





  <link rel="alternate" href="/default" title="刘粉丝来了">






<link rel="canonical" href="http://yoursite.com/2020/06/11/mongodb/"/>


<meta name="description" content="mongodb基本操作 插入多条数据      —       insertMany  查询所有数据      —  find          限制查询条数   — lime(10)    允许查出10条  skip 跳过第几条，从第几条开始查，  skip( 1 )  从第一条开始查  where 查询条件  示例&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D; where({ title:’吴亦凡’ })  只能查出titl">
<meta property="og:type" content="article">
<meta property="og:title" content="mongodb">
<meta property="og:url" content="http://yoursite.com/2020/06/11/mongodb/index.html">
<meta property="og:site_name" content="刘粉丝来了">
<meta property="og:description" content="mongodb基本操作 插入多条数据      —       insertMany  查询所有数据      —  find          限制查询条数   — lime(10)    允许查出10条  skip 跳过第几条，从第几条开始查，  skip( 1 )  从第一条开始查  where 查询条件  示例&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D; where({ title:’吴亦凡’ })  只能查出titl">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-06-11T01:43:51.000Z">
<meta property="article:modified_time" content="2020-06-11T04:41:56.391Z">
<meta property="article:author" content="刘粉丝来了">
<meta property="article:tag" content="node">
<meta name="twitter:card" content="summary">


<link rel="stylesheet" type="text/css" href="/css/style.css?v=1.1" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet'>





<script type="text/javascript">
  var themeConfig = {
    fancybox: {
      enable: false
    },
  };
</script>




  



    <title> mongodb - 刘粉丝来了 </title>
  <meta name="generator" content="Hexo 4.2.0"></head>

  <body>
    <div id="page">
      <header id="masthead"><div class="site-header-inner">
    <h1 class="site-title">
        <a href="/." class="logo">刘粉丝来了</a>
    </h1>

    <nav id="nav-top">
        
            <ul id="menu-top" class="nav-top-items">
                
                    <li class="menu-item">
                        <a href="/">
                            
                            
                                Home
                            
                        </a>
                    </li>
                
                    <li class="menu-item">
                        <a href="/archives">
                            
                            
                                Archives
                            
                        </a>
                    </li>
                
                    <li class="menu-item">
                        <a href="/tags">
                            
                            
                                Tags
                            
                        </a>
                    </li>
                
                    <li class="menu-item">
                        <a href="/about">
                            
                            
                                About
                            
                        </a>
                    </li>
                
            </ul>
        
  </nav>
</div>

      </header>
      <div id="content">
        
    <div id="primary">
        
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          mongodb
        
      </h1>

      <time class="post-time">
          6月 11 2020
      </time>
    </header>



    
            <div class="post-content">
            <h3 id="mongodb基本操作"><a href="#mongodb基本操作" class="headerlink" title="mongodb基本操作"></a><strong>mongodb基本操作</strong></h3><ol>
<li><p>插入多条数据      —       insertMany</p>
</li>
<li><p>查询所有数据      —  find        </p>
</li>
<li><p>限制查询条数   — lime(10)    允许查出10条</p>
</li>
<li><p>skip 跳过第几条，从第几条开始查，  skip( 1 )  从第一条开始查</p>
</li>
<li><p>where 查询条件  示例======= where({ title:’吴亦凡’ })  只能查出title为吴亦凡的</p>
</li>
<li><p>sort   语法示例 —–  sort({ _id:-1 })</p>
<ul>
<li>-1代表倒叙</li>
<li>1代表正叙 </li>
</ul>
</li>
<li><p>findbById( id )              — 查找出指定ID的值</p>
</li>
<li><p>create( 数据 )   —  插入单条数据</p>
</li>
<li><p>save()           —  保存数据    处理完逻辑后利用save()保存到数据库</p>
</li>
<li><p>remove()    —    删除数据</p>
</li>
</ol>
<h3 id="关联"><a href="#关联" class="headerlink" title="关联"></a><strong>关联</strong></h3><h5 id="populate-关联字段名-查找出关联的对应的数据"><a href="#populate-关联字段名-查找出关联的对应的数据" class="headerlink" title="populate( 关联字段名 )     查找出关联的对应的数据"></a>populate( 关联字段名 )     查找出关联的对应的数据</h5>
            </div>
          

    
      <footer class="post-footer">
		
		<div class="post-tags">
		  
			<a href="/tags/node/">node</a>
		  
		</div>
		

        
        
  <nav class="post-nav">
    
      <a class="prev" href="/2020/06/14/nestMongodb/">
        <i class="iconfont icon-left"></i>
        <span class="prev-text nav-default">Nest连接数据库</span>
        <span class="prev-text nav-mobile">上一篇</span>
      </a>
    
    
      <a class="next" href="/2020/05/06/BuildTheFoundation/">
        <span class="next-text nav-default">Webpack基础篇</span>
        <span class="prev-text nav-mobile">下一篇</span>
        <i class="iconfont icon-right"></i>
      </a>
    
  </nav>

        
  <div class="comments" id="comments">
    
  </div>


      </footer>
    
  </article>


    </div>

      </div>

      <footer id="colophon"><script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
<span class="copyright-year" style="width:100%; display:flex; justify-content: space-between;">
    <span>
        
        &copy;
    
        2014 -
    
    2020
    <span class="footer-author">刘粉丝来了.</span>
    <span class="power-by">
        由 <a class="hexo-link" href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a> and <a class="theme-link" href="https://github.com/frostfan/hexo-theme-polarbear" target="_blank" rel="noopener">Polar Bear</a> 强力驱动
    </span>
    </span>
    <span id="busuanzi_container_site_pv">
        本站总访问量<span id="busuanzi_value_site_pv" style="color:red">24280</span>次
    </span>
</span>



      </footer>

      <div class="back-to-top" id="back-to-top">
        <i class="iconfont icon-up"></i>
      </div>
    </div>
    


    




  
    <script type="text/javascript" src="/lib/jquery/jquery-3.1.1.min.js"></script>
  

  

    <script type="text/javascript" src="/js/src/theme.js?v=1.1"></script>
<script type="text/javascript" src="/js/src/bootstrap.js?v=1.1"></script>


  </body>
</html>
